#ifndef __SEMAPHORE_H__
#define __SEMAPHORE_H__

#include "lock/wait.h"

typedef struct semaphore_t semaphore_t;

struct semaphore_t {
    int value;
    waitQueue_t waitQueue;
};

void semaphore_init(semaphore_t* sem, int value);  //初始化信号量
void semaphore_release(semaphore_t* sem);          //释放信号量
void semaphore_acquire(semaphore_t* sem);          //获取信号量
bool semaphore_tryAcquire(semaphore_t* sem);       //尝试获取信号量，获取失败不会被休眠

#endif